<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of Account
 *
 * @author Huỳnh
 */
class Resetting extends Zend_Db_Table_Abstract {

    //put your code here
    protected $_name = 'user_resetting';
    protected $_primary = 'resetting_id';

	public function addResetting($row)
	{
		return $this->insert($row);
	}
	
	public function getResettingByGuid($guid)
	{
		$resettingRowset = $this->fetchAll($this->select()->where('guid = ?',$guid));
		$resetting = $resettingRowset->current();
		return $resetting;
	}
	
	public function getResettingByUserId($user_id)
	{
		$resettingRowset = $this->fetchAll($this->select()->where('user_id = ?',$user_id));
		$resetting = $resettingRowset->current();
		return $resetting;
	}
	
	public function removeResettingByUserId($user_id)
	{
		$this->delete(array("user_id = ?" => $user_id));
	}
	
	public function isRequested($user_id)
	{
		$validator = new Zend_Validate_Db_RecordExists(
		    array(
		        'table' => 'user_resetting',
		        'field' => 'user_id'
		    )
		);
		return $validator->isValid($user_id);
	}
}

?>
